<template>
  <view class="side-nav">
    <view 
      v-for="(item, idx) in categories" 
      :key="idx" 
      class="nav-item" 
      :class="{ active: item.id === activeCategory }"
      @click="emit('change', item.id)"
    >
      <text>{{ item.name }}</text>
    </view>
  </view>
</template>

<script setup>
const props = defineProps({
  categories: { type: Array, required: true }, // 分类数组：[{id, name}]
  activeCategory: { type: String, default: 'hot' }
})
const emit = defineEmits(['change'])
</script>

<style scoped>
.side-nav {
  width: 160rpx;
  background: #f5f5f5;
}
.nav-item {
  padding: 24rpx 0;
  text-align: center;
  font-size: 26rpx;
}
.nav-item.active {
  background: #fff;
  color: #ff6700;
  font-weight: bold;
}
</style>